import { defineStore } from 'pinia';

const useCom = defineStore('comDrag', {
    state: () => {
        return {
            isShowEmptyCom: false, // 是否展示空组件占位
            isDragEnd: false, // 是否拖拽结束
            curDragComSchema: null, //当前拖拽组件的配置信息
            selectedComSchema: null, // 当前选中的组件配置信息
        }
    },
    actions: {
        updateIsShowEmptyCom(flag) {
            this.isShowEmptyCom = flag;
        },
        updateIsDragEnd(flag) {
            this.isDragEnd = flag;
        },
        updateCurDragComSchema(schema) {
            this.curDragComSchema = schema;
            this.selectedComSchema = schema;
        },
        updateSelectedComFromState(formState) {
            this.selectedComSchema.formState = formState;
        },
        reset() {
            this.isDragEnd = false;
            this.curDragComSchema = null;
        }
    }
});

export default useCom;